home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Wipes ƒ / SlideWipe.c < prev    next >
Text File  |  1994-04-19  |  3KB  |  105 lines

  1. /**********************************************************************\
  2.  
  3. File:        SlideWipe.c
  4.  
  5. Purpose:    Graphic effect from offscreen bitmap to main window (on
  6.             screen).  See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 1
  28. #define theWindowWidth (boundsRect.right-boundsRect.left)
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30.  
  31. pascal short SlideWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect);
  32.  
  33. /* Split the screen into 10 sections, then scroll each section left or right
  34.    (alternating), starting with the top section and working towards the bottom. */
  35.    
  36. pascal short SlideWipe(GrafPtr sourceGrafPtr, GrafPtr destGrafPtr, Rect boundsRect)
  37. {
  38.     int                x, y;
  39.     Rect            theRect, dest;
  40.     Rect            scrollsource;
  41.     int                direction;
  42.     int                BoxSize, StripSize;
  43.  
  44.     BoxSize=theWindowWidth/25;
  45.     StripSize=theWindowHeight/10;
  46.     
  47.     direction = 0;
  48.     for(y = 0; y < theWindowHeight; y += StripSize)
  49.     {
  50.         scrollsource = boundsRect;
  51.         scrollsource.top+=y;
  52.         scrollsource.bottom = scrollsource.top + StripSize;
  53.         
  54.         dest = scrollsource;
  55.         
  56.         theRect.top = boundsRect.top + y;
  57.         theRect.bottom = theRect.top + StripSize;
  58.         
  59.         if(direction == 0)
  60.         {
  61.             dest.right = dest.left + BoxSize;
  62.             
  63.             theRect.left = boundsRect.right-BoxSize;
  64.             theRect.right = boundsRect.right;
  65.             
  66.             for(x = boundsRect.right - BoxSize; x >= boundsRect.left; x -= BoxSize)
  67.             {
  68.                 StartTiming();
  69.                 theRect.left = x;
  70.                 ScrollTheRect(&scrollsource, BoxSize, 0, 0L);
  71.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  72.                         &theRect, &dest, 0, 0L);
  73.                 theRect.right = x;
  74.                 TimeCorrection(CorrectTime);
  75.             }
  76.             CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  77.                     &scrollsource, &scrollsource, 0, 0L);
  78.         }
  79.         else
  80.         {
  81.             dest.left = dest.right - BoxSize;
  82.             
  83.             theRect.left = boundsRect.left;
  84.             theRect.right = theRect.left + BoxSize;
  85.             
  86.             for(x = boundsRect.left+BoxSize; x <= boundsRect.right; x += BoxSize)
  87.             {
  88.                 StartTiming();
  89.                 theRect.right = x;
  90.                 ScrollTheRect(&scrollsource, -BoxSize, 0, 0L);
  91.                 CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  92.                         &theRect, &dest, 0, 0L);
  93.                 theRect.left = x;
  94.                 TimeCorrection(CorrectTime);
  95.             }
  96.             CopyBits(&(sourceGrafPtr->portBits), &(destGrafPtr->portBits),
  97.                     &scrollsource, &scrollsource, 0, 0L);
  98.         }
  99.         
  100.         direction = 1 - direction;
  101.     }
  102.     
  103.     return 0;
  104. }
  105.